﻿@using System.ComponentModel

<Table DataSource="data" RowExpandable="@((record)=>record.Data.Name!="Not Expandable")">
    <RowTemplate>
        <Column @bind-Field="@context.Name" />
        <Column @bind-Field="@context.Age" />
        <Column @bind-Field="@context.Address" />
        <ActionColumn Title="Action">
            <a>Delete</a>
        </ActionColumn>
    </RowTemplate>
    <ExpandTemplate>
        @context.Data.Description
    </ExpandTemplate>
</Table>

@code {

    Data[] data =
    {
        new() {
            Key = "1",
            Name = "John Brown",
            Age = 32,
            Address = "New York No. 1 Lake Park",
            Description = "My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park."
        },
        new() {
            Key = "2",
            Name = "Jim Green",
            Age = 42,
            Address = "London No. 1 Lake Park",
            Description = "My name is Jim Green, I am 42 years old, living in London No. 1 Lake Park."
        },
        new() {
            Key = "3",
            Name = "Not Expandable",
            Age = 29,
            Address = "Jiangsu No. 1 Lake Park",
            Description = "This not expandable"
        },
        new() {
            Key = "4",
            Name = "Joe Black",
            Age = 32,
            Address = "Sidney No. 1 Lake Park",
            Description = "My name is Joe Black, I am 32 years old, living in Sidney No. 1 Lake Park."
        }
    };

    public class Data
    {
        [DisplayName("Key")]
        public string Key { get; set; }

        [DisplayName("Name")]
        public string Name { get; set; }

        [DisplayName("Age")]
        public int Age { get; set; }

        [DisplayName("Address")]
        public string Address { get; set; }

        [DisplayName("Description")]
        public string Description { get; set; }
    }
}
